<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // var 可以访问到a
      console.log(a) //undefind
      var a = 100
      console.log(a) //100

      // let
      // console.log(b) // Uncaught ReferenceError: Cannot access 'b' before initialization
      let b = 200
      console.log(b) //200

      /*
    let 与 var 的区别
      
      1、必须先定义再使用
      2、变量重名，可以检查重名问题
      3、块级作用域 {}
      */

      // const
      console.log(c) //Uncaught ReferenceError: Cannot access 'c' before initialization
      const c = 300
      console.log(c) //200

      /*
      let 和 const 的区别 
      
      1、let 定义变量 
      let name="cxm" 
      name="zll"  √

      2、 const定义常量
      const name="cxm"
      name="zll" x
      */
    </script>
  </body>
</html>
